home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / H145.ZIP / ASXXXX_2.ZIP / ASMTST.ASM < prev    next >
Assembly Source File  |  1990-07-18  |  5KB  |  365 lines

  1.     .title    Machine Independent Assembler Test
  2.     .module    Asmtst
  3.  
  4.     .sbttl    Memory Allocation Directives
  5.  
  6.     .radix    O        ;set default to octal
  7.  
  8.     .byte    0b11000000    ;binary constants
  9.     .byte    0B1110
  10.  
  11.     .byte       24        ;octal constants
  12.     .byte      024
  13.     .byte    0q024
  14.     .byte    0Q024
  15.     .byte    0o024
  16.     .byte    0O024
  17.  
  18.     .byte    0d024        ;decimal constant
  19.     .byte    0D024
  20.  
  21.     .byte    0h024        ;hexidecimal constants
  22.     .byte    0H024
  23.     .byte    0x024
  24.     .byte    0X024
  25.  
  26.     .db    0
  27.     .dw    0
  28.  
  29.     .radix    D        ;set default to decimal
  30.  
  31.     .byte    1,2,3,4,5,6,7,8,9
  32.     .word    1,2,3,4,5,6,7,8,9
  33.  
  34.     .blkb    16
  35.     .ds    16
  36.  
  37.     .blkw    16
  38.     .ds    16*2
  39.  
  40. word:    .word    .+2
  41.     .word    .-2
  42.     .word    2+.
  43.     .word    .-(word+2)
  44.  
  45.  
  46.     .sbttl    Boundary Directives
  47.  
  48.     .even
  49.     .byte    0
  50.     .even
  51.     .byte    1
  52.     .even
  53.     .odd
  54.     .byte    2
  55.     .odd
  56.     .byte    3
  57.     .odd
  58.     .even
  59.     .word    4
  60.     .odd
  61.     .word    5
  62.     .even
  63.     .word    6
  64.  
  65.  
  66.     .sbttl    String Directives
  67.  
  68.     .ascii    "abcdefgh"
  69.     .asciz    "abcdefgh"
  70.  
  71.     .page
  72.     .sbttl    Expression Evaluation
  73.  
  74.     n0x00    =    0x00
  75.     n0x01    =    0x01
  76.     n0x10    =    0x10
  77.     n0xff    =    0xff
  78.     n0xeeff    =    0xeeff
  79.  
  80.  
  81.     n    =    'A        ;0x41        single character
  82.     n    =    "AB        ;0x4142        double character
  83.     n    =    n0x01        ;0x01        assignment
  84.     n    =    n + n0x01    ;0x02        addition
  85.     n    =    n - n0x01    ;0x01        subtraction
  86.     n    =    n * 0x05    ;0x05        multiplication
  87.     n    =    n / 0x02    ;0x02        division
  88.     n    =    n0x10 % 0x05    ;0x01        modulus
  89.     n    =    n0x10 | n0x01    ;0x11        or
  90.     n    =    n0xff & n0x01    ;0x01        and
  91.     n    =    n0x01 << 4    ;0x10        left shift
  92.     n    =    n0x10 >> 4    ;0x01        right shift
  93.     n    =    n0xff ^ n0x10    ;0xef        xor
  94.     n    =    n ^ n0x10    ;0xff        xor
  95.     n    =    ~n0x10        ;0xffef        1's complement
  96.     n    =    -n0x10        ;0xfff0        2's complement
  97.  
  98.     n    =    n0xeeff & 0xff    ;0xff        low byte
  99.     n = (n0xeeff & 0xff00)/0x100    ;0xee        high byte
  100.  
  101.     n    =    n0xeeff % 0x100    ;0xff        low byte
  102.     n    =    n0xeeff / 0x100    ;0xee        high byte
  103.  
  104.     n    =    < n0xeeff    ;0xff        low byte
  105.     n    =    > n0xeeff    ;0xee        high byte
  106.  
  107.     n    =    3*(2 + 4*(6))    ;0x4e        expression evaluation
  108.     n    =  2*(0x20 + <~n0x10)    ;0x21e
  109.  
  110.  
  111.  
  112.     .page
  113.     .sbttl    IF, ELSE, and ENDIF
  114.  
  115.     n = 0
  116.     m = 0
  117.  
  118.     .if    0
  119.         n = 1
  120.        .if    0
  121.         m = 1
  122.        .else
  123.         m = 2
  124.        .endif
  125.     .else
  126.         n = 2
  127.     .endif
  128.  
  129.     .byte    n,m        ; n = 2, m = 0
  130.  
  131.     ;*******************************************************
  132.  
  133.     n = 0
  134.     m = 0
  135.  
  136.     .if    1
  137.         n = 1
  138.        .if    0
  139.         m = 1
  140.        .else
  141.         m = 2
  142.        .endif
  143.     .else
  144.         n = 2
  145.     .endif
  146.  
  147.     .byte    n,m        ; n = 1, m = 2
  148.  
  149.  
  150.     .page
  151.  
  152.     n = 0
  153.     m = 0
  154.  
  155.     .if    0
  156.         n = 1
  157.        .if    1
  158.         m = 1
  159.        .else
  160.         m = 2
  161.        .endif
  162.     .else
  163.         n = 2
  164.     .endif
  165.  
  166.     .byte    n,m        ; n = 2, m = 0
  167.  
  168.     ;*******************************************************
  169.  
  170.     n = 0
  171.     m = 0
  172.  
  173.     .if    1
  174.         n = 1
  175.        .if    1
  176.         m = 1
  177.        .else
  178.         m = 2
  179.        .endif
  180.     .else
  181.         n = 2
  182.     .endif
  183.  
  184.     .byte    n,m        ; n = 1, m = 1
  185.  
  186.  
  187.     .page
  188.  
  189.     n = 0
  190.     m = 0
  191.  
  192.     .if    0
  193.         n = 1
  194.     .else
  195.        .if    0
  196.         m = 1
  197.        .else
  198.         m = 2
  199.        .endif
  200.         n = 2
  201.     .endif
  202.  
  203.     .byte    n,m        ; n = 2, m = 2
  204.  
  205.     ;*******************************************************
  206.  
  207.     n = 0
  208.     m = 0
  209.  
  210.     .if    1
  211.         n = 1
  212.     .else
  213.        .if    0
  214.         m = 1
  215.        .else
  216.         m = 2
  217.        .endif
  218.         n = 2
  219.     .endif
  220.  
  221.     .byte    n,m        ; n = 1, m = 0
  222.  
  223.  
  224.     .page
  225.  
  226.     n = 0
  227.     m = 0
  228.  
  229.     .if    0
  230.         n = 1
  231.     .else
  232.        .if    1
  233.         m = 1
  234.        .else
  235.         m = 2
  236.        .endif
  237.         n = 2
  238.     .endif
  239.  
  240.     .byte    n,m        ; n = 2, m = 1
  241.  
  242.     ;*******************************************************
  243.  
  244.     n = 0
  245.     m = 0
  246.  
  247.     .if    1
  248.         n = 1
  249.     .else
  250.        .if    1
  251.         m = 1
  252.        .else
  253.         m = 2
  254.        .endif
  255.         n = 2
  256.     .endif
  257.  
  258.     .byte    n,m        ; n = 1, m = 0
  259.  
  260.  
  261.     .page
  262.     .sbttl    Local Symbols
  263.  
  264. lclsym0:
  265.     .word    0$,1$,2$,3$,4$        ;forward references
  266.     .word    5$,6$,7$,8$,9$
  267.  
  268. 0$:    .word    9$
  269. 1$:    .word    8$
  270. 2$:    .word    7$
  271. 3$:    .word    6$
  272. 4$:    .word    5$
  273. 5$:    .word    4$
  274. 6$:    .word    3$
  275. 7$:    .word    2$
  276. 8$:    .word    1$
  277. 9$:    .word    0$
  278. 10$:
  279.  
  280.     .word    0$,1$,2$,3$,4$        ;backward references
  281.     .word    5$,6$,7$,8$,9$
  282.  
  283. lclsym1:
  284.     .word    0$,1$,2$,3$,4$        ;forward references
  285.     .word    5$,6$,7$,8$,9$
  286.  
  287. 0$:    .word    9$
  288. 1$:    .word    8$
  289. 2$:    .word    7$
  290. 3$:    .word    6$
  291. 4$:    .word    5$
  292. 5$:    .word    4$
  293. 6$:    .word    3$
  294. 7$:    .word    2$
  295. 8$:    .word    1$
  296. 9$:    .word    0$
  297. 10$:
  298.  
  299.     .word    0$,1$,2$,3$,4$        ;backward references
  300.     .word    5$,6$,7$,8$,9$
  301.  
  302.     .sbttl    Offset calculations
  303.  
  304.     ofsbyte    =    (10$-0$)    ;0x0014
  305.     ofsword    =    ofsbyte/2    ;0x000A
  306.  
  307.     .word    1$+ofsbyte+ofsword    ;1$ + 0x001E
  308.  
  309.     .page
  310.     .sbttl    Area Definitions
  311.  
  312.     .globl    code0
  313.     .globl    cnstnt1,cnstnt2
  314.  
  315.     cnstnt0 == 0xabcd        ; global equate
  316.  
  317. code0:    .word    a0
  318.     .word    cnstnt0
  319.  
  320.     .area    A (OVR)
  321.     cnstnt1 = 0x1234
  322.  
  323. a0:    .word    0x00ff
  324.  
  325.     .area    B (ABS,OVR)
  326.     cnstnt2 = 0x5678
  327.  
  328.     .word    a1
  329.  
  330.     .area    A
  331.  
  332.     .=.+0x0020
  333.     .word    a2
  334.  
  335.     .area    B
  336.     .org    0x40
  337.  
  338.     .word    a0,a1,a2
  339.     .word    B,OVR
  340.  
  341. abcdabcd::                ; global symbol
  342.  
  343.     .page
  344.     .sbttl    Assembler Output File asmtst.sym
  345.  
  346. ;    assembled by:
  347. ;         asxxxx -glosx asmtst
  348.  
  349.     .sbttl    Symbol Table
  350.  
  351. ;    B          **** GX  |     OVR        **** GX  |   1 a0         0000 R
  352. ;    a1         **** GX  |     a2         **** GX  |   2 abcdabcd   004A GR
  353. ;    cnstnt0 =  ABCD G   |     cnstnt1 =  1234 G   |     cnstnt2 =  5678 G
  354. ;  0 code0      0141 GR  |   0 lclsym0    00C7 R   |   0 lclsym1    0103 R
  355. ;    m       =  0000     |     n       =  0001     |     n0x00   =  0000 
  356. ;    n0x01   =  0001     |     n0x10   =  0010     |     n0xeeff =  EEFF 
  357. ;    n0xff   =  00FF     |     ofsbyte =  0014     |     ofsword =  000A 
  358. ;  0 word       008C R
  359.  
  360.     .sbttl    Area Table
  361.  
  362. ;   0 _CODE      size  145   flags 0
  363. ;   1 A          size   24   flags 4
  364. ;   2 B          size   4A   flags C
  365.